package com.xiaotu.code.service.mquene;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xiaotu.code.dao.quene.SettingMqQueneDao;
import com.xiaotu.code.model.quene.SettingMqQuene;
import com.xiaotu.code.system.ServiceException;

/**
 * MQ队列配置.
 * 
 * @author liqinghua
 * 
 */
@Service("settingMqQueneService")
@Transactional(rollbackFor = Exception.class)
public class SettingMqQueneServiceImpl implements SettingMqQueneService {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3549374667243031434L;

	/**
	 * 
	 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	private SettingMqQueneDao settingMqQueneDao;

	@Override
	public List<SettingMqQuene> getEnabledList() throws ServiceException {
		try {
			return settingMqQueneDao.getEnabledList();
		} catch (Exception e) {
			logger.error("获取已启用的队列列表错误", e);
			throw new ServiceException(e);
		}
	}

	@Override
	public List<SettingMqQuene> getLitenerList() throws ServiceException {
		try {
			
			return settingMqQueneDao.getLitenerList(0);
		} catch (Exception e) {
			logger.error("获取本节点需要监听的队列列表错误", e);
			throw new ServiceException(e);
		}
	}

	@Override
	public SettingMqQuene getLitenerByQueneName(String queneName) throws ServiceException {
		try {
			return settingMqQueneDao.getLitenerByQueneName(queneName, 0);
		} catch (Exception e) {
			logger.error("获取获取本节点需要发送的消息体接受者错误", e);
			throw new ServiceException(e);
		}
	}
}
